import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * a Runnable for using WatchDir in new thread  
 * 
 * @author Vladimir Sarkisyan & Erez Levy
 *
 */
public class WatcherAPI implements Runnable{
	 BufferedReader in;
	 PrintWriter out;
	 
	//constructor
	public WatcherAPI(BufferedReader in, PrintWriter out){
		this.in=in;this.out=out;
	}
	
	/**
	 * get the path of the directory that the files are
	 * and activate the WatchDir
	 * 
	 */
	@Override
	public void run() {
		// TODO Auto-generated method stub
		 Path dir = Paths.get(Declarations.instance.getPath());
			// TODO Auto-generated method stub
	        try {
				new WatchDir(dir, false, in, out).processEvents();
				
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}

}
